﻿using System;
using UnityEngine;

namespace UniRx.Examples
{
	// Token: 0x020001E6 RID: 486
	public class Sample04_ConvertFromUnityCallback : MonoBehaviour
	{
		// Token: 0x06000A32 RID: 2610 RVA: 0x00036CF0 File Offset: 0x000350F0
		private void Awake()
		{
			(from x in Sample04_ConvertFromUnityCallback.LogHelper.LogCallbackAsObservable()
			where x.LogType == LogType.Warning
			select x).Subscribe(delegate(Sample04_ConvertFromUnityCallback.LogCallback x)
			{
				Debug.Log(x);
			});
			(from x in Sample04_ConvertFromUnityCallback.LogHelper.LogCallbackAsObservable()
			where x.LogType == LogType.Error
			select x).Subscribe(delegate(Sample04_ConvertFromUnityCallback.LogCallback x)
			{
				Debug.Log(x);
			});
		}

		// Token: 0x020001E7 RID: 487
		private class LogCallback
		{
			// Token: 0x040006B3 RID: 1715
			public string Condition;

			// Token: 0x040006B4 RID: 1716
			public string StackTrace;

			// Token: 0x040006B5 RID: 1717
			public LogType LogType;
		}

		// Token: 0x020001E8 RID: 488
		private static class LogHelper
		{
			// Token: 0x06000A38 RID: 2616 RVA: 0x00036DC0 File Offset: 0x000351C0
			public static IObservable<Sample04_ConvertFromUnityCallback.LogCallback> LogCallbackAsObservable()
			{
				return Observable.FromEvent<Application.LogCallback, Sample04_ConvertFromUnityCallback.LogCallback>((Action<Sample04_ConvertFromUnityCallback.LogCallback> h) => delegate(string condition, string stackTrace, LogType type)
				{
					h(new Sample04_ConvertFromUnityCallback.LogCallback
					{
						Condition = condition,
						StackTrace = stackTrace,
						LogType = type
					});
				}, delegate(Application.LogCallback h)
				{
					Application.logMessageReceived += h;
				}, delegate(Application.LogCallback h)
				{
					Application.logMessageReceived -= h;
				});
			}
		}
	}
}
